]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowMenu: Check if monitorIndex is valid before using it
authorSam Spilsbury <sam@endlessm.com>
Wed, 11 Oct 2017 10:42:04 +0000 (18:42 +0800)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 28 Jun 2018 14:29:07 +0000 (16:29 +0200)
Calling meta_window_get_monitor on an unmanaged window may return
-1, so we need to check the return value.

https://bugzilla.gnome.org/show_bug.cgi?id=788882

js/ui/windowMenu.js

index f0e564b7ec77de24795d10f2c087807b3d0fe39a..d4411d01575427920051d8e330136e32dcbce259 100644 (file)
@@ -128,11 +128,10 @@ var WindowMenu = new Lang.Class({
 
         let screen = global.screen;
         let nMonitors = screen.get_n_monitors();
-        if (nMonitors > 1) {
+        let monitorIndex = window.get_monitor();
+        if (nMonitors > 1 && monitorIndex >= 0) {
             this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
 
-            let monitorIndex = window.get_monitor();
-
             let dir = Meta.ScreenDirection.UP;
             let upMonitorIndex =
                 screen.get_monitor_neighbor_index(monitorIndex, dir);